package com.zwz.mall.constants;

import android.Manifest;
import android.Manifest.permission;
import android.annotation.SuppressLint;
import android.support.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * @Author: EzerXie
 * @Description:
 * @Date: Created on 2018/11/7 14:59
 * @Modified By:
 */
public class Constants
{
    public static final String URL = "url";
    public static final String SHARE_URL = "share_url";
    public static final String SHARE_Title = "share_title";
    public static final String ACTIVITY_TITTLE = "activityTittle";
    public static final String SHARE_CONTENT = "content";
    public static final String SHOW_TITTLE = "showTittle";
    public static final String CUSTOME_TITTLE = "customeTittle";
    public static final String EDUCATION_ICON = "education_icon";
    public static final String TOKEN = "token";
    public static final String TIME_DIFFERENCE = "time_difference";
    public static final String KEY = "6Z*d02wRE43IRNJ^";

    @SuppressLint("InlinedApi")
    public static final class PermissionConstants {

        public static final String CALENDAR   = Manifest.permission_group.CALENDAR;
        public static final String CAMERA     = Manifest.permission_group.CAMERA;
        public static final String CONTACTS   = Manifest.permission_group.CONTACTS;
        public static final String LOCATION   = Manifest.permission_group.LOCATION;
        public static final String MICROPHONE = Manifest.permission_group.MICROPHONE;
        public static final String PHONE      = Manifest.permission_group.PHONE;
        public static final String SENSORS    = Manifest.permission_group.SENSORS;
        public static final String SMS        = Manifest.permission_group.SMS;
        public static final String STORAGE    = Manifest.permission_group.STORAGE;

        private static final String[] GROUP_CALENDAR   = {
                permission.READ_CALENDAR, permission.WRITE_CALENDAR
        };
        private static final String[] GROUP_CAMERA     = {
                permission.CAMERA
        };
        private static final String[] GROUP_CONTACTS   = {
                permission.READ_CONTACTS, permission.WRITE_CONTACTS, permission.GET_ACCOUNTS
        };
        private static final String[] GROUP_LOCATION   = {
                permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION
        };
        private static final String[] GROUP_MICROPHONE = {
                permission.RECORD_AUDIO
        };
        private static final String[] GROUP_PHONE      = {
                permission.READ_PHONE_STATE, permission.READ_PHONE_NUMBERS, permission.CALL_PHONE,
                permission.ANSWER_PHONE_CALLS, permission.READ_CALL_LOG, permission.WRITE_CALL_LOG,
                permission.ADD_VOICEMAIL, permission.USE_SIP, permission.PROCESS_OUTGOING_CALLS
        };
        private static final String[] GROUP_SENSORS    = {
                permission.BODY_SENSORS
        };
        private static final String[] GROUP_SMS        = {
                permission.SEND_SMS, permission.RECEIVE_SMS, permission.READ_SMS,
                permission.RECEIVE_WAP_PUSH, permission.RECEIVE_MMS,
        };
        private static final String[] GROUP_STORAGE    = {
                permission.READ_EXTERNAL_STORAGE, permission.WRITE_EXTERNAL_STORAGE
        };

        @StringDef({CALENDAR, CAMERA, CONTACTS, LOCATION, MICROPHONE, PHONE, SENSORS, SMS, STORAGE,})
        @Retention(RetentionPolicy.SOURCE)
        public @interface Permission {
        }

        public static String[] getPermissions(@Permission final String permission) {
            switch (permission) {
                case CALENDAR:
                    return GROUP_CALENDAR;
                case CAMERA:
                    return GROUP_CAMERA;
                case CONTACTS:
                    return GROUP_CONTACTS;
                case LOCATION:
                    return GROUP_LOCATION;
                case MICROPHONE:
                    return GROUP_MICROPHONE;
                case PHONE:
                    return GROUP_PHONE;
                case SENSORS:
                    return GROUP_SENSORS;
                case SMS:
                    return GROUP_SMS;
                case STORAGE:
                    return GROUP_STORAGE;
            }
            return new String[]{permission};
        }
    }


}
